use serde::Deserialize;
use serde::Serialize;
use ts_rs::TS;
use yata::core::PeriodType;
use yata::core::ValueType;

use super::IndicatorActionWrap;

///
/// Struct to hold the results of Struct yata::indicators::ChaikinOscillator.
///
///  参见[CKO](https://en.wikipedia.org/wiki/Chaikin_Analytics)
///
#[derive(Serialize, Deserialize, Default, Debug, TS, Clone)]
#[ts(export)]
pub struct CKO {
    /// 1 signal
    ///When oscillator value goes above zero, then returns full buy signal.
    /// When oscillator value goes below zero, then returns full sell signal.
    /// Otherwise no signal
    pub signal0: Option<IndicatorActionWrap>,

    /// 1 value
    /// oscillator value
    /// Range in [-1.0; 1.0]
    pub oscillator: ValueType,
}

/// Configuration for Struct yata::indicators::AwesomeOscillator, Awesome Oscillator
#[derive(Serialize, Deserialize, Debug, TS, Clone, Copy)]
#[ts(export)]
pub struct CKOConfig {
    ///    ma1: M
    ///Short smoothing AD index.
    ///
    ///Default is EMA(3).
    ///
    ///Range in [1; ma2’s period)
    ///
    pub ma1: PeriodType,
    ///ma2: M
    ///Long smoothing AD index.
    ///
    ///Default is EMA(10).
    ///
    ///Range in (period1; PeriodType::MAX)
    ///
    pub ma2: PeriodType,
    ///window: PeriodType
    ///AD index size. Default is 0 (windowless)
    ///
    ///Range in [0; PeriodType::MAX]
    pub window: PeriodType,
}

impl Default for CKOConfig {
    fn default() -> Self {
        Self {
            ma1: 3,
            ma2: 10,
            window: 0,
        }
    }
}
